<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    // var out = 'hello'
    // function foo() {
    //   console.log(out)
    //   out = null
    // }
    // foo()
    function foo() {
      var num = 2
      function sum() {
        num++
        return num //2
      }
      return sum
    }
    var jieguo = function () {
      num++
      return num //2
    } //
    console.log(jieguo()) //2
    console.log(jieguo()) //3
    // 访问变量 先找同级的这个变量 同级找不到 往上找
  </script>
</html>
